Skip to content

Conversation

@DarkIsDude
Copy link
Contributor

@DarkIsDude DarkIsDude self-assigned this Jan 8, 2026
@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 64.28571% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.33%. Comparing base (535b360) to head (a8eba02).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
lib/api/bucketGet.js 61.53% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
lib/api/metadataSearch.js 76.38% <100.00%> (+0.33%) ⬆️
lib/routes/veeam/list.js 97.50% <ø> (ø)
lib/api/bucketGet.js 93.15% <61.53%> (-3.09%) ⬇️

... and 1 file with indirect coverage changes

@@                                     Coverage Diff                                     @@
##           feature/CLDSRV-812/list-objects-v2-optional-permissions    #6043      +/-   ##
===========================================================================================
- Coverage                                                    84.36%   84.33%   -0.03%     
===========================================================================================
  Files                                                          204      204              
  Lines                                                        12935    12949      +14     
===========================================================================================
+ Hits                                                         10912    10920       +8     
- Misses                                                        2023     2029       +6     
Flag Coverage Δ
file-ft-tests 67.42% <50.00%> (-0.02%) ⬇️
kmip-ft-tests 28.10% <0.00%> (-0.04%) ⬇️
mongo-v0-ft-tests 68.68% <57.14%> (+0.01%) ⬆️
mongo-v1-ft-tests 68.67% <57.14%> (-0.03%) ⬇️
multiple-backend 35.35% <35.71%> (+<0.01%) ⬆️
sur-tests 36.44% <0.00%> (+0.73%) ⬆️
sur-tests-inflights 37.45% <0.00%> (-0.05%) ⬇️
unit 69.97% <57.14%> (+0.04%) ⬆️
utapi-v2-tests 34.37% <35.71%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-813/optional-attributes-response branch 2 times, most recently from 229fe35 to 1fde211 Compare January 9, 2026 10:42
@DarkIsDude DarkIsDude force-pushed the feature/CLDSRV-813/optional-attributes-response branch from 1fde211 to a8eba02 Compare January 9, 2026 11:13
@DarkIsDude DarkIsDude requested review from a team, benzekrimaha and maeldonn January 9, 2026 11:46
Comment on lines +268 to +274
for (const key of Object.keys(item)) {
if (key.startsWith('x-amz-meta-')) {
if (optionalAttributes.includes('x-amz-meta-*') || optionalAttributes.includes(key)) {
xml.push(`<${key}>${item[key]}</${key}>`);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be more efficient to go the other way round:

  • e.g. go through every optionalAttributes (which are more likely not as numerous as the fields in our metadata objects)
  • in particular, this also ensure we keep the "usual" case (e.g. without optionalAttributes) optimized.
  • it avoids the repeated lookups in optionalAttributes
for(const attr  in optionalAttributes) {
   switch (attr) {
   case 'RestoreStatus':
     [...]
	 break;

   case 'x-amz-meta-*':
     for ((key, value) in item.getUserMetadata()) {
        xml.push(`<${key}>${item[key]}</${key}>`);
     }
     break;

   default:
     const v = item[attr];
     if (v !== undefined) {
         xml.push(....)
     }
     break;
   }

The x-amz-meta-* case is a bit more concerning, since

  • it needs to go through every field to get the every user metadata (but there is already the ObjectMD.getUserMetadata() function to do this)
  • there could be an issue if both x-amz-meta-* and specific fields are specified ; but this should be rejected when validating the request?

This approach is also more future-proof, as it will allow to ad more fields by simply adding them to the optionalAttributes list during validation (i.e. less coupling, only need to update one place if we add more fields later)

}

function clearUploadIdFromVersions(versions) {
function clearUploadIdFromVersionsAndRestoreStatus(versions) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function clearUploadIdFromVersionsAndRestoreStatus(versions) {
function clearUploadIdAndRestoreStatusFromVersions(versions) {

for (const version of versions) {
if (version.value) {
version.value.uploadId = undefined;
version.value.restoreStatus = undefined;
Copy link
Contributor

@francoisferrand francoisferrand Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to clear RestoreStatus from all of these tests?

RestoreStatus is only set by cold storage, so will not be set in most case : so seems best to keep this "as is" and handle the cold-storage tests


for (const version of versions) {
if (version.value) {
version.value.restoreStatus = undefined;
Copy link
Contributor

@francoisferrand francoisferrand Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to clear RestoreStatus in every test?

all APIs should behave the same as before, so you should not need to tweak the tests
(and resetting restoreStatus may be expected -if anywhere- only in tests where you do actually invoke the list object v2 api with optional attributes)

done();
});
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the x-amz-optional-attributes header tests from previous PR should be updated: some tests where actually not really testing much (or duplicated) since the result was not observable...

assert.strictEqual(err, null);
assert.strictEqual(result.ListBucketResult.$.xmlns, 'http://s3.amazonaws.com/doc/2006-03-01/');
done();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have some functional tests as well : i.e. tests using the AWS sdk to retrieve the values from a running cloudserver service.

As an extra benefit, it would also provide an exemple of how to use the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new test on lowerCase (all usermetadata are lowercase)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants